package com.jindy.module.projectcostdetails.controller;

import com.jindy.common.annotation.Log;
import com.jindy.common.core.controller.BaseController;
import com.jindy.common.core.domain.AjaxResult;
import com.jindy.common.core.page.TableDataInfo;
import com.jindy.common.enums.BusinessType;
import com.jindy.module.projectcostdetails.domain.ProjectCostDetails;
import com.jindy.module.projectcostdetails.service.ProjectCostDetailsService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 项目费用明细Controller
 *
 * @author zhaoxi
 * @date 2022-11-12
 */
@Api(tags = "业务后台 - 项目费用明细管理 ")
@RestController
@RequestMapping("/module/projectcostdetails")
@Validated
@Slf4j
public class ProjectCostDetailsController extends BaseController {

    @Autowired
    private ProjectCostDetailsService projectCostDetailsService;

    /**
     * 查询 项目费用明细列表
     */
    @GetMapping("/list")
//    @PreAuthorize("@ss.hasPermi('module:projectcostdetails:list')")
    public TableDataInfo list(ProjectCostDetails details){
        startPage();
        List<ProjectCostDetails> list = projectCostDetailsService.selectProjectCostDetailsList(details);
        return getDataTable(list);
    }

    /**
     * 根据id查询项目费用明细信息
     */
//    @PreAuthorize("@ss.hasPermi('module:projectcostdetails:id')")
    @GetMapping(value = "/{id}")
    public AjaxResult get(@PathVariable("id") String id) {
        return AjaxResult.success(projectCostDetailsService.selectProjectCostDetailsById(id));
    }

    /**
     * 新增项目费用明细数据
     */
    @Log(title = "新增项目费用明细", businessType = BusinessType.INSERT)
//    @PreAuthorize("@ss.hasPermi('module:projectcostdetails:add')")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody ProjectCostDetails details)
    {
        return toAjax(projectCostDetailsService.insertProjectCostDetails(details));
    }

    /**
     * 修改项目费用明细数据
     */
    @Log(title = "修改项目费用明细", businessType = BusinessType.UPDATE)
//    @PreAuthorize("@ss.hasPermi('module:projectcostdetails:update')")
    @PutMapping("/update")
    public AjaxResult update(@RequestBody ProjectCostDetails details) {
        return toAjax(projectCostDetailsService.updateProjectCostDetails(details));
    }

    /**
     * 删除项目费用明细
     */
    @Log(title = "删除项目费用明细", businessType = BusinessType.DELETE)
//    @PreAuthorize("@ss.hasPermi('module:projectcostdetails:delete')")
    @DeleteMapping("/remove/{id}")
    public AjaxResult remove(@PathVariable String id)
    {
        return toAjax(projectCostDetailsService.deleteProjectCostDetailsById(id));
    }

    /**
     * 批量删除
     */
    @Log(title = "批量删除", businessType = BusinessType.DELETE)
//    @PreAuthorize("@ss.hasPermi('module:projectcostdetails:deletes')")
    @DeleteMapping("/{ids}")
    public AjaxResult removes(@PathVariable String[] ids)
    {
        return toAjax(projectCostDetailsService.deleteProjectCostDetailsByIds(ids));
    }
}
